﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<script>
    $(function () {
        SearchUserData();

    })
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            $('#pageIndexNow').val(1);
            var searchname = $("#username").val();
            $("#hiddenname").val(searchname);
            SearchUserData();
        }
    });
    function SearchUserData() {
        $("#searchflage").val(1);  //按用户名检索标识
        var searchUserForm = $('#searchUserForm');
        searchUserForm.submit();
    }
    function SearchUser() { //检索按钮
        $('#pageIndexNow').val('1');//每次点击检索将页码初始化为1
        var searchname = $("#username").val();
        $("#hiddenname").val(searchname);
        SearchUserData();
    }
    //点击分页
    function searchPageNew(n) {
        $('#pageIndexNow').val(n);
        if ($("#searchflage").val() == 1) {
            SearchUserData();
        }
        else {
            LoadData();
        }
    }
    function GroupChange() {
        $('#pageIndexNow').val(1);
        $("#searchflage").val(0);  //按用户组检索标识
        LoadData();
    }
    function LoadData() {
        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("GetListByGroupName", "Admin_User"))"),
            data: { "groupvalue": $('#groupValue').val(), "pageIndexNow": $('#pageIndexNow').val() },
            beforeSend: function () { $("#loading").show(); },
            success: function (msg) {
                $("#docListUser").html("");
                $("#docListUser").html(msg);
                $("#loading").hide();
            },
            error: function (e)
            { $("#loading").hide(); }
        })
    }

</script>
<div class="wrapR-h" style="padding-top: 20px; padding-bottom: 20px">
    <div class="form form-h">
        @using (Ajax.BeginForm("Search", new { }, new AjaxOptions()
        {
            HttpMethod = "post",
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "docListUser",
            LoadingElementId = "loading"
        }, new { id = "searchUserForm" }))
        { 
            <input type="hidden" id="pageIndexNow" name="pageIndexNow" value="1" />
            <input type="hidden" id="searchflage" value="1" />
            <div class="f-gp" style="float:left">
                <div class="f-lb">
                    <label class="f-label">用户查询：</label>
                </div>
                <div class="f-ct f-ml">
                    <input type="text" class="f-text span4" name="username" id="username" maxlength="255">
                    <input type="hidden" class="f-text span4" name="hiddenname" id="hiddenname">
                    <a class="btn btn-submit btn-warn-f" onclick="SearchUser()">检索</a>
                </div>

            </div>
            <div class="f-gp" style="float:left;margin-left:50px">

                <div class="f-lb" style="text-align: right">
                    <label class="f-label">组用户查看：</label>
                </div>
                <div class="f-ct">
                    @if (ViewBag.UserGroupList != null)
                    {
                        <select class="f-select span3" id="groupValue" onchange="GroupChange()">
                            <option value="0" selected="selected">所有类型</option>
                            @foreach (SYS_CMS_GROUP item in ViewBag.UserGroupList)
                            {
                                <option value="@item.SysID">@item.Name</option>
                            }
                        </select>
                    }
                </div>
            </div>

        }
    </div>
</div>
<div class="wrapR-c">
    <div id="docListUser">
    </div>
</div>



